package 验证二叉搜索树;

import tree_node.TreeNode;

class Solution {
    public long prev = Long.MIN_VALUE;
    public boolean isValidBST(TreeNode root) {
        if(root == null){
            return true;
        }
        boolean left = isValidBST(root.left);
        if(!left){
            return false;
        }
        if(root.val > prev){
            prev = root.val;
        }else{
            return false;
        }
        boolean right = isValidBST(root.right);
        return right;
    }
}